<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" 
          "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>QUnit for key of X.509 Certificate 'x509.js'</title>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
<script type="text/javascript" src="jquery-1.4.2.min.js"></script>
<script type="text/javascript" src="qunit.js"></script>
<link rel="stylesheet" href="qunit.css" type="text/css" media="screen" />

<script src="../ext/cj/cryptojs-312-core-fix.js"></script>
<script src="../ext/cj/x64-core.js"></script>
<script src="../ext/cj/cipher-core_min.js"></script>
<script src="../ext/cj/aes_min.js"></script>
<script src="../ext/cj/tripledes_min.js"></script>
<script src="../ext/cj/enc-base64_min.js"></script>
<script src="../ext/cj/md5_min.js"></script>
<script src="../ext/cj/sha1_min.js"></script>
<script src="../ext/cj/sha256_min.js"></script>
<script src="../ext/cj/sha224_min.js"></script>
<script src="../ext/cj/sha512_min.js"></script>
<script src="../ext/cj/sha384_min.js"></script>
<script src="../ext/cj/ripemd160_min.js"></script>
<script src="../ext/cj/hmac_min.js"></script>
<script src="../ext/cj/pbkdf2_min.js"></script>

<script src="../ext/jsbn.js"></script>
<script src="../ext/jsbn2.js"></script>
<script src="../ext/rsa.js"></script>
<script src="../ext/rsa2.js"></script>
<script src="../ext/base64.js"></script>
<script src="../ext/prng4.js"></script>
<script src="../ext/rng.js"></script>
<script src="../ext/ec.js"></script>
<script src="../ext/ec-patch.js"></script>

<script src="../src/base64x-1.1.js"></script>
<script src="../src/asn1hex-1.1.js"></script>
<script src="../src/crypto-1.1.js"></script>
<script src="../src/rsapem-1.1.js"></script>
<script src="../src/x509-1.1.js"></script>
<script src="../src/keyutil-1.0.js"></script>
<script src="../src/ecdsa-modified-1.0.js"></script>
<script src="../src/ecparam-1.0.js"></script>

<script type="text/javascript">
$(document).ready(function(){

// _test/z1.cer (RSA)
var z1CertPEM = "" +
"-----BEGIN CERTIFICATE-----\n" +
"MIIBdTCCAR+gAwIBAgIBBTANBgkqhkiG9w0BAQUFADAaMQswCQYDVQQGEwJVUzEL\n" +
"MAkGA1UECgwCYTEwHhcNMTMwNTA0MDM0MTQxWhcNMjMwNTA0MDM0MTQxWjAaMQsw\n" +
"CQYDVQQGEwJVUzELMAkGA1UECgwCYTEwXDANBgkqhkiG9w0BAQEFAANLADBIAkEA\n" +
"6GZN0rQFKRIVaPOzm8l6Yue6PAm6vcTw3NjfkOt5C5u2RaK3DjESdHtNPEG1FCSJ\n" +
"URX++I951D6uWxpONRj9WQIDAQABo1AwTjAdBgNVHQ4EFgQUxUc+4gDI561wA9/1\n" +
"QguM3fTCDhUwHwYDVR0jBBgwFoAUxUc+4gDI561wA9/1QguM3fTCDhUwDAYDVR0T\n" +
"BAUwAwEB/zANBgkqhkiG9w0BAQUFAANBALL2k69LjwOYfDXv3TXJUAFGUqto+Noj\n" +
"CJLP08fOfNBZy+KAIy0GsrNU/3uRViqbuGqAnH9kFFwHQjOAFrAe8XQ=\n" +
"-----END CERTIFICATE-----\n";

// _gitpg/jsrsasign/test/eckey/k1.self.cer
var k1CertPEM = "" +
"-----BEGIN CERTIFICATE-----\n" +
"MIIBfDCCASGgAwIBAgIJAKbxELQvSUDNMAoGCCqGSM49BAMCMBoxCzAJBgNVBAYT\n" +
"AlVTMQswCQYDVQQKDAJLMTAeFw0xMzA3MTQwMjE3MTdaFw0yMzA3MTIwMjE3MTda\n" +
"MBoxCzAJBgNVBAYTAlVTMQswCQYDVQQKDAJLMTBZMBMGByqGSM49AgEGCCqGSM49\n" +
"AwEHA0IABKAVMqPAkABT3mD77+/MpYeTMBWY0wi0Hm9ONk44jCcRvvQyxZkUjJQU\n" +
"PU/0bCy3Pj5qQdfu8jwEfqEeYGZ95CWjUDBOMB0GA1UdDgQWBBTIR74yfMz/Y4hw\n" +
"dXSW4r42bESo/DAfBgNVHSMEGDAWgBTIR74yfMz/Y4hwdXSW4r42bESo/DAMBgNV\n" +
"HRMEBTADAQH/MAoGCCqGSM49BAMCA0kAMEYCIQDfAcS/WKBrP6JBgksQVpp4jdq4\n" +
"C53Yu4F5NkaMgthAHgIhANGRdWAP1QdW9l6tiglQwdqJs4T0e8+NYv+RcAb3VYwn\n" +
"-----END CERTIFICATE-----\n";

var k5CertPem = "" +
"-----BEGIN CERTIFICATE-----\n" +
"MIICETCCAXKgAwIBAgIUYcEvdqjSYTHDXGJJMmK76h+q/bYwCgYIKoZIzj0EAwQw\n" +
"GjELMAkGA1UEBhMCVVMxCzAJBgNVBAoMAks1MB4XDTIxMTEyNzEwMzgyMFoXDTQx\n" +
"MTEyMjEwMzgyMFowGjELMAkGA1UEBhMCVVMxCzAJBgNVBAoMAks1MIGbMBAGByqG\n" +
"SM49AgEGBSuBBAAjA4GGAAQA0ppSNEw1EZ/1vqGa4JD4AtBf+eoxrcwxUk0BKHXq\n" +
"eRNEsCrwa1jePD0m8bpBPSXVz5trKHtcnPQQvypup60CYZ0A3iIVAqFUgPBk2dBM\n" +
"C9QHE+WHynL8MAnTOJR0VNY2F7YuCKQv6YIBU9zfiERZkujPIE2M78QmTA1J2B4p\n" +
"gwftaY+jUzBRMB0GA1UdDgQWBBRlDRyXy9CrDdTZW7gEIWipef3DhzAfBgNVHSME\n" +
"GDAWgBRlDRyXy9CrDdTZW7gEIWipef3DhzAPBgNVHRMBAf8EBTADAQH/MAoGCCqG\n" +
"SM49BAMEA4GMADCBiAJCAV4C6IirulahutoguAzYfHsFZieP6Z5tqm0ql/bXsDgd\n" +
"ZqxlrvTrpbHjSZr8vROiDPWaj9umJz2R8EOGk36vTY0MAkIAo2TRkneSYP3ZDjSh\n" +
"+29UnKQBS2/JazRBJ5ztk58L+4UkPInmj4lWXk3Rzhi8h2lKWVPK/5oq1KcvvHpd\n" +
"JPZcEXw=\n" +
"-----END CERTIFICATE-----\n";
    
test("getPublicKeyFromCertPEM z1CertPEM(RSA)", function() {
  var key = X509.getPublicKeyFromCertPEM(z1CertPEM);
  equal(key.type, "RSA", "type");
  equal(key.n.compareTo(new BigInteger("00e8664dd2b40529121568f3b39bc97a62e7ba3c09babdc4f0dcd8df90eb790b9bb645a2b70e3112747b4d3c41b51424895115fef88f79d43eae5b1a4e3518fd59", 16)), 0, "compare z1.n");
  equal(key.e, 65537, "z1.e(65537)");
});

test("getPublicKeyFromCertPEM k1CertPEM(ECC)", function() {
  var key = X509.getPublicKeyFromCertPEM(k1CertPEM);
  equal(key.type, "EC", "type");
  equal(key.curveName, "secp256r1", "curveName");
  equal(key.pubKeyHex, "04a01532a3c0900053de60fbefefcca58793301598d308b41e6f4e364e388c2711bef432c599148c94143d4ff46c2cb73e3e6a41d7eef23c047ea11e60667de425", "pubKeyHex");
});

test("getPublicKeyFromCertPEM(ECC P-521)", function() {
  var key = X509.getPublicKeyFromCertPEM(k5CertPem);
  equal(key.type, "EC", "type");
  equal(key.curveName, "secp521r1", "curveName");
  equal(key.pubKeyHex, "0400d29a52344c35119ff5bea19ae090f802d05ff9ea31adcc31524d012875ea791344b02af06b58de3c3d26f1ba413d25d5cf9b6b287b5c9cf410bf2a6ea7ad02619d00de221502a15480f064d9d04c0bd40713e587ca72fc3009d338947454d63617b62e08a42fe9820153dcdf88445992e8cf204d8cefc4264c0d49d81e298307ed698f", "pubKeyHex");
});


});
</script>
  
</head>
<body>
<div id="qunit"></div>
<div id="qunit-fixture">test markup</div>

<p>
<a href="../">TOP</a> | 
<a href="index.html">TEST INDEX</a> | 
<a href="qunit-do-x509.html">x509</a> | 
<a href="qunit-do-x509-ext.html">x509-ext</a> | 
<a href="qunit-do-x509-key.html">x509-key</a> | 
<a href="qunit-do-x509-kid.html">x509-kid</a> | 
<a href="qunit-do-x509-getinfo.html">x509-getinfo</a> | 
<a href="qunit-do-x509-v1.html">x509-v1</a> | 
</p>

</body>
<center><p>&copy; 2010-2016 Kenji Urushima</p></center>
</html>


